﻿using Direct.IDAL.Manager.UserCenter;
using DirectSell.Common.Filter;
using Microsoft.Practices.Unity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

namespace DirectSell.WebLayer.Areas.Manager.Controllers
{
    /// <summary>
    /// 后台推荐结构图
    /// </summary>
    public class BackRefreeMapController : Controller
    {

        #region 注入
        [Dependency]
        protected IBackRefreeMapRepository _repository { get; set; }
        #endregion

        #region 首页
        /// <summary>
        /// 首页
        /// </summary>
        /// <returns></returns>
        [ManagerFilter(IsCheck =true)]
        public ActionResult Index()
        {
            return View();
        }
        #endregion

        #region 获取树状图
        /// <summary>
        /// 获取树状图
        /// </summary>
        /// <returns></returns>
        public async Task<ActionResult> GetTreeList()
        {
            var list = await _repository.GetZtreeList(25);
            return Json(list, JsonRequestBehavior.AllowGet);
        }
        #endregion

        #region 获取下一级
        /// <summary>
        /// 获取下一级
        /// </summary>
        /// <returns></returns>
        public async Task<ActionResult> GetNextList(int id)
        {
            var list = await _repository.GetNext(id);
            return Json(list, JsonRequestBehavior.AllowGet);
        }
        #endregion

    }
}